// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   register_ok.java

package oa.message;

import com.jspsmart.upload.*;
import include.nseer_cookie.*;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class register_ok extends HttpServlet
{

	public register_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			ServletContext context = session.getServletContext();
			String path = context.getRealPath("/");
			counter count = new counter(dbApplication);
			SmartUpload mySmartUpload = new SmartUpload();
			mySmartUpload.setCharset("UTF-8");
			nseer_db_backup1 oa_db = new nseer_db_backup1(dbApplication);
			if (oa_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				getAttachmentLength getAttachmentLength = new getAttachmentLength();
				getAttachmentType getAttachmentType = new getAttachmentType();
				double d = getAttachmentLength.getAttachmentLength((String)dbSession.getAttribute("unit_db_name"), "document_config_public_char");
				String ee = getAttachmentType.getAttachmentType((String)dbSession.getAttribute("unit_db_name"), "document_config_public_char");
				mySmartUpload.initialize(pageContext);
				mySmartUpload.upload();
				String file_name[] = new String[mySmartUpload.getFiles().getCount()];
				int j = 0;
				int filenum1 = count.read((String)dbSession.getAttribute("unit_db_name"), "oaMessagecount");
				String message_ID = (new StringBuilder(String.valueOf(filenum1))).toString();
				count.write((String)dbSession.getAttribute("unit_db_name"), "oaMessagecount", filenum1);
				String sql1 = (new StringBuilder("select * from oa_message where message_ID='")).append(message_ID).append("'").toString();
				ResultSet rs = oa_db.executeQuery(sql1);
				if (j != 0 || rs.next())
				{
					response.sendRedirect("oa/message/register_ok_a.jsp");
				} else
				{
					String subject = mySmartUpload.getRequest().getParameter("subject");
					String message_type = mySmartUpload.getRequest().getParameter("message_type");
					String register = mySmartUpload.getRequest().getParameter("register");
					String register_ID = mySmartUpload.getRequest().getParameter("register_ID");
					String register_time = mySmartUpload.getRequest().getParameter("register_time");
					String bulletin = mySmartUpload.getRequest().getParameter("bulletin");
					String content = exchange.toHtmlFCK(mySmartUpload.getRequest().getParameter("content"));
					String bodyab = new String(mySmartUpload.getRequest().getParameter("remark").getBytes("UTF-8"), "UTF-8");
					String remark = exchange.toHtml(bodyab);
					if (j != 0)
					{
						response.sendRedirect("oa/message/register_ok_c.jsp");
					} else
					{
						String sqla = "";
						String sqlb = "";
						if (bulletin == null)
						{
							sqla = "insert into oa_message(register,register_ID,register_time,message_ID,subject,type,content,remark";
							sqlb = (new StringBuilder(") values ('")).append(register).append("','").append(register_ID).append("','").append(register_time).append("','").append(message_ID).append("','").append(subject).append("','").append(message_type).append("','").append(content).append("','").append(remark).append("'").toString();
						} else
						{
							sqla = "insert into oa_message(register,register_ID,register_time,message_ID,subject,type,content,remark,check_tag";
							sqlb = (new StringBuilder(") values ('")).append(register).append("','").append(register_ID).append("','").append(register_time).append("','").append(message_ID).append("','").append(subject).append("','").append(message_type).append("','").append(content).append("','").append(remark).append("','2'").toString();
						}
						String sql = (new StringBuilder(String.valueOf(sqla))).append(sqlb).append(")").toString();
						oa_db.executeUpdate(sql);
						response.sendRedirect("oa/message/register_ok_b.jsp");
					}
				}
				oa_db.commit();
				oa_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
